package com.platform.common.constant;

import java.time.Duration;

/**
 * @author GH
 */
public class RedisConstants {

    public static final String ALL_URL_PERMISSION = "allUrlPermission";
    public static final String URL_TO_ROLES_MAP = "urlToRolesMap";
    public static final String URL_TO_ROLES = "urlToRoles";

    public static final String USER_ID_TO_USERNAME = "userIdToUsername";
    public static final String USER_ID_TO_NICKNAME = "userIdToNickname";
    public static final String USERNAME_TO_USERID = "usernameToUserId";
    public static final String USER_ID_TO_ROLES = "userIdToRoles";

    public static final String PROBLEM_ID_TO_PROBLEM_TITLE = "problemIdToProblemTitle";
    public static final String PROBLEM_ID_TO_PROBLEM_CHECKPOINT_NUM = "problemIdToProblemCheckpointNum";
    public static final String PROBLEM_CODE_TO_PROBLEM_ID = "problemCodeToProblemId";
    public static final String PROBLEM_ID_TO_PROBLEM_CODE = "problemIdToProblemCode";

    /** token过期时间 */
    public static final Duration HULA_TOKEN_EXPIRE = Duration.ofDays(7);

    public static final Duration CAPTCHA_EXPIRE = Duration.ofMinutes(5);


    /**============== 分布式锁 ==================== */

    public static String getRefreshTokenLockKey(Long uId) {
        return "refreshTokenLock:" + uId;
    }

    /** ------------- 验证码 ---------------------- */
    public static String getCaptchaKey(String uuid) {
        return "captch:" + uuid;
    }

    /** ------------- 忘记密码token ---------------------- */
    public static String getForgetPasswordKey(String uuid) {
        return "forgetPassword:" + uuid;
    }

    /** ------------- 邮件发送间隔token ---------------------- */
    public static String getEmailIntervalKey(String email) {
        return "emailInterval:" + email;
    }

    /** ------------- 邮箱验证token ---------------------- */
    public static String getEmailCodeKey(String email) {
        return "emailCode:" + email;
    }

    public static String getContestRank(long contestId) {
        return "contestRank:" + contestId;
    }

    /** =============== 第三方认证相关 ================= */
    public static String getThirdPartyToken(String uuid) {
        return "ThirdParty:" + uuid;
    }
}